<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<title></title>
    <link rel="stylesheet" href="<?php echo STATICURL; ?>css/bootstrap.min.css" />
    <link rel="stylesheet" href="<?php echo STATICURL; ?>css/bootstrap.min.css" />
    <link rel="stylesheet" href="<?php echo STATICURL; ?>css/bootstrap-responsive.min.css" />
    <link rel="stylesheet" href="<?php echo STATICURL; ?>css/colorpicker.css" />
    <link rel="stylesheet" href="<?php echo STATICURL; ?>css/datepicker.css" />
    <link rel="stylesheet" href="<?php echo STATICURL; ?>css/uniform.css" />
    <link rel="stylesheet" href="<?php echo STATICURL; ?>css/select2.css" />
    <link rel="stylesheet" href="<?php echo STATICURL; ?>css/matrix-style.css" />
    <link rel="stylesheet" href="<?php echo STATICURL; ?>css/matrix-media.css" />
    <link rel="stylesheet" href="<?php echo STATICURL; ?>css/bootstrap-wysihtml5.css" />
    <link href="<?php echo STATICURL; ?>font-awesome/css/font-awesome.css" rel="stylesheet" />
</head>

<body style="background: #eeeeee;">
    <div class="widget-content" >
        <table class="table" style="margin-top: 20px;">
            <tbody>
            <tr>
                <td>姓名</td>
                <td><input id="username" type="text" value="<?=$userInfo->username?>"  placeholder="请输入用户名"/></td>
            </tr>
            <tr>
                <td>账号</td>
                <td><input id="email" type="text" value="<?=$userInfo->email?>"  placeholder="请输入邮箱"/></td>
            </tr>
            <tr>
                <td>新密码</td>
                <td><input id="J_newpassword" type="password" placeholder="●●●●●●" /></td>
            </tr>
            <tr>
                <td>再次输入新密码</td>
                <td><input id="J_verify_psw" type="password" placeholder="●●●●●●"/></td>
            </tr>
            <tr>
                <td>分配角色</td>
                <td>
                    <div class="control-group">
                        <div class="controls">
                            <select id="chooserole">
                                    <option value = "0">---请分配角色---</option>
                                <?php foreach($role_name_list as $key=>$row):?>
                                    <option <?php if($userInfo->roleid == $key):?>selected="selected" <?php endif;?> value = "<?php echo $key;?>"><?php echo $row?></option>
                                <?php endforeach;?>
                            </select>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td>启用状态</td>
                <td>
                    <div class="control-group">
                        <div class="controls">
                            <label>
                                <input type="radio" <?php if($userInfo->status == 1):?>checked="checked"<?php endif;?> name="radios" />
                                启用</label>
                            <label>
                                <input type="radio" <?php if($userInfo->status == -1):?>checked="checked"<?php endif;?> name="radios" />
                                停用</label>
                        </div>
                    </div>
                </td>
            </tr>

            <tr>
                <td style="border-right: 0;">&nbsp;</td>
                <td style="border-left: 0;"><a style="float:left" type="submit" class="js_btn btn btn-success" href="javascript:void(0)" id="edit_manager">保存</a></td>
            </tr>
            </tbody>
        </table>
    </div>
</body>
<script src="<?php echo STATICURL; ?>js/jquery.min.js"></script>
<script src="<?php echo STATICURL; ?>js/bootstrap.min.js"></script>
<script src="<?php echo STATICURL; ?>js/matrix.js"></script>
<script src="<?php echo STATICURL; ?>js/jquery.uniform.js"></script>
<script src="<?php echo STATICURL; ?>js/select2.min.js"></script>
<script src="<?php echo STATICURL; ?>js/matrix.form_common.js"></script>
<script src="<?php echo STATICURL; ?>js/bootstrap-wysihtml5.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $("#edit_manager").click(function(){
            var username = $("#username").val();
            var email = $("#email").val();
            var password = $("#J_newpassword").val();
            var verify_psw = $("#J_verify_psw").val();
            var roleid = $("#chooserole").val();
            var id = "<?php echo $id?>";
            if(username == '')
            {
                alert("姓名不能为空");
                return false;
            }
            if(email== '')
            {
                alert("账号邮箱不能为空");
                return false;
            }
            if(password == ""){
                alert("密码不能为空");
                return false;
            }
            if(password != "" || verify_psw != "")
            {
                if(password != verify_psw)
                {
                    alert("两次密码不一致");
                    return false;
                }
            }
            if(roleid == "0"){
                alert("请分配角色");
                return false;
            }
            $.post("/luckydog/account/edit_account",{"username":username,"password":password,'email':email,'roleid':roleid,"id":id},function(res){
                if (res.code == 1) {
                    alert('保存成功');
                     window.parent.location.reload();
                } else if(res.code < 0)
                {
                    alert(res.message);
                }
            },"json");
        });
    });
</script>